package net.togogo.egouweb1238.core.service.product.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.togogo.egouweb1238.core.dao.product.ImgDao;
import net.togogo.egouweb1238.core.domain.product.Img;
import net.togogo.egouweb1238.core.query.product.ImgQuery;
import net.togogo.egouweb1238.core.service.product.IImgService;
/**
 * 
 * @author stone
 */
@Service
@Transactional
public class ImgServiceImpl implements IImgService {

	@Resource
	private ImgDao imgDao;

	/**
	 * 插入数据库
	 * 
	 * @return
	 */
	public Integer addImg(Img img) {
		return imgDao.addImg(img);
	}

	/**
	 * 根据主键查找
	 */
	@Transactional(readOnly = true)
	public Img getImgById(Integer id) {
		return imgDao.getImgById(id);
	}
	
	@Transactional(readOnly = true)
	public List<Img> getImgsByIds(List<Integer> idList) {
		return imgDao.getImgsByIds(idList);
	}

	/**
	 * 根据主键删除
	 * 
	 * @return
	 */
	public Integer deleteById(Integer id) {
		return imgDao.deleteById(id);
	}

	public Integer deleteByIds(List<Integer> idList) {
		return imgDao.deleteByIds(idList);
	}

	/**
	 * 根据主键更新
	 * 
	 * @return
	 */
	public Integer updateImgById(Img img) {
		return imgDao.updateImgById(img);
	}
	
//	@Transactional(readOnly = true)
//	public Pagination getImgListWithPage(ImgQuery imgQuery) {
//		Pagination p = new Pagination(imgQuery.getPageNo(),imgQuery.getPageSize(),imgDao.getImgListCount(imgQuery));
//		p.setList(imgDao.getImgListWithPage(imgQuery));
//		return p;
//	}
	
	@Transactional(readOnly = true)
	public List<Img> getImgList(ImgQuery imgQuery) {
		return imgDao.getImgList(imgQuery);
	}
}
